<!DOCTYPE HTML>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<!--[if lt IE 9]>
    <script type="text/javascript" src="../../../lib/html5shiv.js?rev=@@hash"></script>
    <script type="text/javascript" src="../../../lib/respond.min.js?rev=@@hash"></script>
    <![endif]-->
		<link rel="stylesheet" type="text/css" href="../../../static/h-ui/css/H-ui.min.css" />
		<link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/css/H-ui.admin.css" />
		<link rel="stylesheet" type="text/css" href="../../../lib/Hui-iconfont/1.0.8/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/skin/default/skin.css" id="skin" />
		<link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/css/style.css" />
		<link rel="stylesheet" type="text/css" href="../../../ht-css/Project.css" />
		<!--[if IE 6]>
    <script type="text/javascript" src="../../../lib/DD_belatedPNG_0.0.8a-min.js?rev=@@hash"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
		<link rel="stylesheet" type="text/css" href="../../../ht-css/style-q.css" />
		<title></title>
	</head>

	<body>
		<div class="ml-20 mt-20 mb-20 mr-20">
			<div class="">
				<span style="margin-left: 199px;">请选择取消订单的理由</span>
				<span class="select-box size-M radius mb-15" style="background: #fff">
        <select class="select" name="" id="reason">
			<option value="" selected="selected">请选择取消理由</option>
            <option value="10" >客户订购错误/计划有变</option>
            <option value="11">价格高</option>
            <option value="12">无法满足到货时效</option>
            <option value="13">支付问题</option>
            <option value="14">重复下单</option>
            <option value="15">暂时不需要了</option>
            <option value="16">订单信息有误</option>
            <option value="17">无货</option>
            <option value="18">其他</option>
			<option value="19">商品质量问题</option>
            <option value="20">价格错误</option>
        </select>
        </span>
			</div>
			<div class="formControls mb-20">
				<textarea class="textarea radius" name="" id="cancle-remark" cols="30" rows="10" maxlength="500" placeholder="录入取消说明"></textarea>
				<span class="errorMsg hide" style="color: red;">超出字符限制</span>
			</div>
			<div style="text-align: center">
				<a onclick="cancelBtn()" id="cancelBtn" class="btn btn-secondary radius size-S ml-20">取消</a>
				<a onclick="sureBtn()" id="sureBtn" class="btn btn-secondary radius size-S ml-20">确认</a>
			</div>
		</div>
	</body>
	<!--_footer 作为公共模版分离出去-->
	<script type="text/javascript" src="../../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
	<script type="text/javascript" src="../../../lib/layer/2.4/layer.js?rev=@@hash"></script>
	<script type="text/javascript" src="../../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
	<script type="text/javascript" src="../../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script>
	<!--/_footer 作为公共模版分离出去-->
	<!--请在下方写此页面业务相关的脚本-->
	<script type="text/javascript" src="../../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
	<!--表单验证-->
	<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
	<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
	<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/messages_zh.js?rev=@@hash"></script>
	<script type="text/javascript" src="../../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
	<script type="text/javascript" src="../../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
	<script src="../../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../../ht-js/verifyToken.js?rev=@@hash"></script>
	<script src="../../../ht-js/Project.js?rev=@@hash"></script>
	<script>
		var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
        var isIng = false;
		function sureBtn() {
           /* if(isIng){
                layer.msg('请求已提交，请勿重复点击！');
                return false;
            }
            isIng = true;*/
            if($("#cancle-remark").val().length > 100) {
                $("#cancle-remark").css({
                    border: "1px red solid"
                });
                $(".errorMsg").css({
                    display: "inline"
                });
            } else {
            	if($("#reason").val()==""){
					$.Huimodalalert('请选择取消理由！',2000);
					return false;
				}
            	if(sessionStorage.getItem("stater")==1){


                $.ajax({
                    contentType: "application/json",
                    type: "POST",
                    url: root.dockingplatform.cancelopenPlatformPreOrder,
                    cache: false, //禁用缓存
                    dataType: "json",
                    data: JSON.stringify({
						orderId: orderDetail.orderBase.order_id,
						cancelName: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
						cancelReason: $("#reason").val(),
						cancelRemark: $("#cancle-remark").val(),
						cancelId:JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID
                    }),
                    success: function(result) {
						if (result.errorCode=='0'){
							$.Huimodalalert("成功",2000);
                            sessionStorage.setItem("mark",123);
                            var index = parent.location.reload();
                            parent.layer.close(index);
						}else {
							$.Huimodalalert(result.msg,2000);
						}
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        //alert(JSON.stringify(XMLHttpRequest));
                        $.Huimodalalert("取消失败",2000);
                        isIng = false;
                    }
                });
				}else {
					$.ajax({
						contentType: "application/json",
						type: "POST",
						url: root.orderInter.order_cancleOrder,
						cache: false, //禁用缓存
						dataType: "json",
						data: JSON.stringify({
							order_id: orderDetail.orderBase.order_id,
							member_id: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
							cancle_name: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
							shop_id: orderDetail.orderBase.shop_id,
							warehouse_id: orderDetail.orderBase.warehouse_id,
							cancel_order_status: orderDetail.orderBase.order_status,
							cancel_role: 20,
							cancle_reason: $("#reason").val(),
							cancel_remark: $("#cancle-remark").val(),
                            "operate_userid":JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                            "operate_username":JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name
						}),
						success: function(result) {
							console.log(result)
							if (result.message=='SUCCESS'){
								alert("成功");
							}else {
								alert(result.message);
							}


							var index = parent.location.reload();
							parent.layer.close(index);
						},
						error: function(XMLHttpRequest, textStatus, errorThrown) {
							//alert(JSON.stringify(XMLHttpRequest));
							layer.msg('请求失败，请刷新后重试！');
							isIng = false;
						}
					});
				}
            }
		}

		function cancelBtn() {
			parent.layer.closeAll();
		}
	</script>

</html>